package com.csii.modules.online.cgform.enhance.a;

import com.alibaba.fastjson.JSONObject;
import java.util.Map;
import com.csii.modules.online.cgform.enhance.CgformEnhanceJavaInter;
import com.csii.modules.online.config.exception.BusinessException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component("cgformEnhanceImportDemo")
public class CgformEnhanceImportDemo implements CgformEnhanceJavaInter {
   private static final Logger log = LoggerFactory.getLogger(CgformEnhanceImportDemo.class);

   public int execute(String tableName, JSONObject json) throws BusinessException {
      log.info("--------我是自定义java增强测试bean 导入示例-----------");
      log.info("--------当前tableName=>" + tableName);
      log.info("--------当前JSON数据=>" + json.toJSONString());
      if (json.get("ee") == null) {
         return 1;
      } else if (json.getString("ee").equals("hello")) {
         json.put("id", "testid123");
         json.put("ee", "java 增强导入测试修改");
         return 2;
      } else {
         return json.getString("ee").equals("ok") ? 0 : 1;
      }
   }

   public int execute(String tableName, Map<String, Object> map) throws BusinessException {
      return 1;
   }
}
